#ifndef CANSWER_H_
#define CANSWER_H_

#include <etel.h>
#include <etelmm.h>

#include <cdbcols.h>
#include <e32std.h>
#include <cntdb.h>
#include <cntitem.h>
#include <cpbkcontactitem.h>
#include <flogger.h>

#include "Common.h"
#include "CConfig.h"
#include "CControlConnection.h"


//Info : http://discussion.forum.nokia.com/forum/archive/index.php/t-6574.html

class CAnswer: public CActive
{
private:

	enum TEngineState
        {
        EWaitingIncomingCall, //Waiting
        EInCall //Busy
        };
    
    enum TEngineState iState; 
	// connect to the Etel server RTelServer
	RTelServer itelserver;
	/*** open the phone using RPhone ***/
	RPhone iphone;
	RTelServer::TPhoneInfo phoneInfo;
	RPhone::TLineInfo lineVoiceInfo;
	/*** open the line using RLine ***/
	RLine voiceline;
	RMobilePhone irmobilephone;
	RMobileCall ircall;
	RCall::TStatus callStatus;
	TName callName;
	RLine::TLineInfo lineInfo;
	//TRequestStatus status;
	TInt lineNum;
	TBuf<PHONENUMBERLENGTH> iPhoneNumber;
	CConfig* iConfig;
	CControlConnection* iControlConnection;
	MDisplayObserver& iDisplay;
	#ifdef __LOGGER
		RFileLogger iLog;
	#endif
		
    void DoCancel();
    void RunL();
	void ConstructL(MDisplayObserver& aDisplay);
	void WaitForACallL();
	void StartL();
	void Stop();
	
public:
	
	CAnswer(MDisplayObserver& aDisplay);
	static CAnswer *NewL(MDisplayObserver& aDisplay);
	virtual ~CAnswer(); 
    void StartManually(); 
    void StopManually();
    CConfig* getConfig();
    CControlConnection* getControlConnection();
    void setPhoneNumber(const TDesC& aPhoneNumber);
};

#endif /*CANSWER_H_*/
